<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserInfoPost extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            // unique:albums,name,'.$this->userId.'user_id
//            'user_id' => 'required|numeric|unique:groups|max:255',
            'nickname' => 'sometimes|required|string|min:1|max:15|unique:user_info,nickname',
            'avatar' => 'sometimes|required|string',
            'intro' => 'sometimes|required|string',
        ];
    }

    /**
     * 获取已定义的验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'nickname.required' => '昵称不能为空',
            'nickname.unique' => '昵称已存在',
            'nickname.min' => '昵称长度不能少于1个字',
            'nickname.max' => '昵称长度不能多于15个字',
            'background.unique' => '背景图片不能为空',
            'intro.required'  => '简介不能为空',
        ];
    }
}
